- /*
- When press y | Y key return 1
- n | N key return 0
- usage : cerr << "Quit ? (Y/N)"; YesOrNo();
- */
- #include <stdio.h>
- int YesOrNo(){
- int c, yn = -1;
- do {
- c = getchar();
- getchar(); // clear '\n' in key buffer. Need ?
- if(c == 'y' || c == 'Y') yn = 1;
- else if(c == 'n' || c == 'N') yn = 0;
- else putchar('\a');
- } while( yn < 0);
- return yn;
- }
YesOrNo.cpp : last modifiled at 2017/07/16 16:00:01(371 bytes)
created at 2017/10/03 15:03:21
The creation time of this html file is 2017/10/07 10:54:16 (Sat Oct 07 10:54:16 2017).